<?php
/**
 * @version		$Id: categoriesmultiple.php 842 2011-06-23 11:21:41Z lefteris.kavadas $
 * @package		K2
 * @author		JoomlaWorks http://www.joomlaworks.gr
 * @copyright	Copyright (c) 2006 - 2011 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

 
jimport('joomla.form.formfield');
class JFormFieldK2tags extends JFormField {

	var	$type = 'K2tags';

	function getInput(){ 
 
		  $db = JFactory::getDBO();
		  $query = " SELECT * FROM #__k2_tags_xref tags_xref  LEFT JOIN #__k2_tags tags ON tags.id = tags_xref.tagID WHERE published=1 GROUP BY tags.id ORDER BY name" ;
		  $db->setQuery( $query );
		  
		  $data = $db->loadObjectList();
		 $items = array(); 
		 foreach ( $data as $item ) {
 
			$items[] = JHTML::_('select.option',  $item->id, '   '.$item->name . " (id: ".$item->id.")" );
		}
		$output= JHTML::_('select.genericlist',  $items, $this->name."[]", 'class="inputbox" style="width:90%;" multiple="multiple" size="10" ', 'value', 'text', $this->value, $this->id );
		
		return $output;
	}
}
 